package cn.tedu.charging_user.controller;

import cn.tedu.charging.common.pojo.JsonResult;
import cn.tedu.charging.common.pojo.vo.UserInfoVo;
import cn.tedu.charging_user.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "用户模块")
@Slf4j
@RestController
@RequestMapping("user")
public class UserController {
  @Autowired
  private UserService userService;
  @ApiOperation("获取用户信息")
  @GetMapping("/info/{userId}")
  public JsonResult<UserInfoVo> getUserInfo(@PathVariable("userId") Integer userId){
    log.debug("获取用户信息-入参:{}",userId);
    UserInfoVo userInfoVo = userService.getUserInfo(userId);
    log.debug("获取用户信息-入参:{},出参:{}",userId,userInfoVo);

       /* JsonResult<UserInfoVO> result = new JsonResult<>();
        result.setData(userInfoVO);
        result.setCode(2000); //2000 表示成功
        result.setMessage("获取用户信息成功");*/
    JsonResult<UserInfoVo> result = JsonResult.ok(userInfoVo, "获取用户信息成功");
    log.debug("获取用户信息-入参:{},出参:{}",userId,result);
    return result;
  }

}
